#include <iostream>
#include "CBufferedStream.h"

using namespace std;

int main(int argc,char *argv[])
{

	if(argc<2) {
		cout << "Usages : " << argv[0] << " -f <file>" << endl;
		exit(-1);
	}


	if(strcmp(argv[1],"-f")==0) {
		CBufferedStream buf(argv[2]);
		istream is(&buf);

		long previous = buf.tellg();

		char c;
		for(long pos=buf.size();pos>=0;pos--) {
			buf.seekg(pos);
			previous = buf.tellg();
			if(!is.get(c).fail()) cout << c;
			else is.clear();
			buf.seekg(previous);
		}
	}
}
